package cn.car.constants;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.function.Supplier;

public class CarAccessConstants {

    private static final ThreadLocal<SimpleDateFormat> sdf = ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyyMMdd"));


    private static final Supplier<String> PICTURE_FILE_PATH_WINDOWS = () -> String.join(File.separator, "D:", "car-access", getNowDayStr(), "picture");
    private static final Supplier<String> PICTURE_FILE_PATH_MAC = () -> "/Users/huangjin/hj";

    private static final Supplier<String> VIDEO_FILE_PATH_WINDOWS = () -> String.join(File.separator, "D:", "car-access", getNowDayStr(), "video");
    private static final Supplier<String> VIDEO_FILE_PATH_MAC = () -> "~/car-access/" + getNowDayStr() + "/video/";


    private static String getNowDayStr() {
        // 计算今天的日期，例如：2024年12月2日就是 20241202
        final Date now = new Date();
        return sdf.get().format(now);
    }

    public static Supplier<String> getPictureFilePath() {
        final String os = System.getProperty("os.name");
        return os.toLowerCase().contains("mac") ? PICTURE_FILE_PATH_MAC : PICTURE_FILE_PATH_WINDOWS;
    }

    public static Supplier<String> getVideoFilePath() {
        final String os = System.getProperty("os.name");
        return os.toLowerCase().contains("mac") ? VIDEO_FILE_PATH_MAC : VIDEO_FILE_PATH_WINDOWS;
    }
}
